package com.zb.mobile.network.controller;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.zb.entity.AccounLoginInfo;
import com.zb.entity.RemarkVo;
import com.zb.entity.SelectVo;
import com.zb.entity.ZjWorkOrder;
import com.zb.exception.SMSException;
import com.zb.mobile.*;
import com.zb.mobile.network.service.ConNetworkOrderMobileService;
import com.zb.network.service.ConNetworkEmpService;
import com.zb.order.service.ConWorkOrderService;
import com.zb.result.PageUtil;
import com.zb.result.Result;
import com.zb.service.*;
import com.zb.utils.TokenNetworkUtil;
import com.zb.vo.OrderLeaveMessageVo;
import com.zb.vo.OrderReservationTimeVo;
import com.zb.vo.WorkCallPhoneLogVo;
import com.zb.vo.WorkSpareVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.List;
import java.util.Map;

/**
 * @Author WEN
 * @Date 2023/11/22 0022
 **/
@Api(tags = "服务商移动端工单类接口")
@RestController
@RequestMapping("/mobile/network/order")
public class NetworkOrderMobileController {
    @Resource
    private ConNetworkOrderMobileService conNetworkOrderMobileService;
    @Resource
    private ConWorkOrderService conWorkOrderService;
    @Resource
    private ZjWorkLogService workLogService;
    @Resource
    private ConNetworkEmpService conNetworkEmpService;
    @Resource
    private ZjNetworkEmpCommonFunctionService networkEmpCommonFunctionService;
    @Resource
    private ZjWorkSuspendService workSuspendService;
    @Resource
    private ZjWorkUserService workUserService;

    @ApiOperation("获取状态数量")
    @GetMapping("/getToDoQty")
    public Result getToDoQty(HttpServletRequest request) {
        AccounLoginInfo loginInfo = TokenNetworkUtil.getAccountLoginInfo(request);
        return Result.success().data(PageUtil.row(conNetworkOrderMobileService.getToDoQty(loginInfo)));
    }

    @ApiOperation("获取服务人员常用功能")
    @GetMapping("/getNetworkEmpCommonFunction")
    public Result getNetworkEmpCommonFunction(HttpServletRequest request) {
        AccounLoginInfo loginInfo = TokenNetworkUtil.getAccountLoginInfo(request);
        return Result.success("获取服务人员常用功能成功").data(PageUtil.rows(networkEmpCommonFunctionService.getNetworkEmpCommonFunction(loginInfo)));
    }

    @ApiOperation("保存服务人员常用功能")
    @PostMapping("/saveNetworkEmpCommonFunction")
    public Result saveNetworkEmpCommonFunction(HttpServletRequest request, @RequestBody @ApiParam(value = "常用功能类型：1-创建服务商，2-加入服务商，3-认证中心，" +
            "4-工单统计，5-工单报表，6-个人仓库，7-我的账户，8-邀请成员，9-库存明细", required = true, example = "[1,2,3,4]") List<Integer> types) {
        AccounLoginInfo loginInfo = TokenNetworkUtil.getAccountLoginInfo(request);
        networkEmpCommonFunctionService.saveNetworkEmpCommonFunction(loginInfo, types);
        return Result.success("保存常用功能成功");
    }

    @ApiOperation("获取侧边栏数据")
    @GetMapping("/getSidebarData")
    public Result getSidebarData(HttpServletRequest request) {
        AccounLoginInfo loginInfo = TokenNetworkUtil.getAccountLoginInfo(request);
        return Result.success("获取侧边栏数据成功").data(PageUtil.rows(conNetworkOrderMobileService.getSidebarData(loginInfo)));
    }

    @ApiOperation("获取工单合计(首页-工单统计-工单合计)")
    @PostMapping("/getNetworkOrderStat")
    public Result getNetworkOrderStat(HttpServletRequest request, @RequestBody NetworkOrderStatSelectVo selectVo) {
        AccounLoginInfo loginInfo = TokenNetworkUtil.getAccountLoginInfo(request);
        return Result.success().data(PageUtil.row(conNetworkOrderMobileService.getNetworkOrderStat(loginInfo, selectVo)));
    }

    @ApiOperation("获取服务商近七天的工单数")
    @PostMapping("/getNetworkInSevenDaysOrder")
    public Result getNetworkInSevenDaysOrder(HttpServletRequest request) {
        AccounLoginInfo loginInfo = TokenNetworkUtil.getAccountLoginInfo(request);
        return Result.success("获取服务商近七天的工单数成功").data(PageUtil.rows(conNetworkOrderMobileService.getNetworkInSevenDaysOrder(loginInfo)));
    }

    @ApiOperation("获取排行榜数据")
    @PostMapping("/getNetworkOrderScoreStat")
    public Result getNetworkOrderScoreStat(HttpServletRequest request, @RequestBody NetworkOrderStatSelectVo selectVo) {
        AccounLoginInfo loginInfo = TokenNetworkUtil.getAccountLoginInfo(request);
        return Result.success("获取排行榜数据").data(PageUtil.row(conNetworkOrderMobileService.getNetworkOrderScoreStat(loginInfo, selectVo)));
    }

    @ApiOperation("获取工单报表(工单类型占比)")
    @PostMapping("/getNetworkOrderModuleStat")
    public Result getNetworkOrderModuleStat(HttpServletRequest request, @RequestBody NetworkOrderStatSelectVo selectVo) {
        AccounLoginInfo loginInfo = TokenNetworkUtil.getAccountLoginInfo(request);
        return Result.success("获取工单报表类型占比数据成功").data(PageUtil.row(conNetworkOrderMobileService.getNetworkOrderModuleStat(loginInfo, selectVo)));
    }

    @ApiOperation("获取工单报表(工单分析)")
    @GetMapping("/getWeekOrderStat")
    public Result getWeekOrderStat(HttpServletRequest request) {
        AccounLoginInfo loginInfo = TokenNetworkUtil.getAccountLoginInfo(request);
        return Result.success("获取工单报表分析数据成功").data(PageUtil.row(conNetworkOrderMobileService.getWeekOrderStat(loginInfo)));
    }

    @ApiOperation("获取服务商消息列表")
    @PostMapping("/getNetworkOrderMessageList")
    public Result getNetworkOrderMessageList(HttpServletRequest request, @RequestBody NetworkMobileOrderMessageListSelectVo selectVo) {
        AccounLoginInfo loginInfo = TokenNetworkUtil.getAccountLoginInfo(request);
        return Result.success().data(conNetworkOrderMobileService.getNetworkOrderMessageList(loginInfo, selectVo));
    }

    @ApiOperation("更新未读留言")
    @PutMapping("/updateNetworkOrderNotReadMessage/{workId}")
    public Result updateNetworkOrderNotReadMessage(HttpServletRequest request, @PathVariable @ApiParam(value = "工单ID", required = true) Long workId) {
        AccounLoginInfo loginInfo = TokenNetworkUtil.getAccountLoginInfo(request);
        conNetworkOrderMobileService.updateNetworkOrderNotReadMessage(loginInfo, workId);
        return Result.success();
    }

    @ApiOperation("根据工单ID获取留言列表")
    @PostMapping("/getNetworkOrderMessage/{workId}")
    public Result getNetworkOrderMessage(HttpServletRequest request, @PathVariable @ApiParam(value = "工单ID", required = true) Long workId, @RequestBody PageUtil pageUtil) {
        AccounLoginInfo loginInfo = TokenNetworkUtil.getAccountLoginInfo(request);
        return Result.success().data(conNetworkOrderMobileService.getNetworkOrderMessage(loginInfo, workId, pageUtil));
    }

    @ApiOperation("保存服务商的工单留言")
    @PostMapping("/saveNetworkOrderMessage")
    public Result saveNetworkOrderMessage(HttpServletRequest request, @RequestBody @Valid OrderLeaveMessageVo leaveMessageVo) {
        AccounLoginInfo loginInfo = TokenNetworkUtil.getAccountLoginInfo(request);
        conWorkOrderService.saveNetworkWorkLeaveMessage(loginInfo, leaveMessageVo);
        return Result.success();
    }

    @ApiOperation("获取服务商工单列表状态数量")
    @PostMapping("/getNetworkOrderListStatusQty")
    public Result getNetworkOrderListStatusQty(HttpServletRequest request, @RequestBody(required = false) @ApiParam(value = "搜索关键词：工单单号/一物一码/产品名称/产品型号") String keyword) {
        AccounLoginInfo loginInfo = TokenNetworkUtil.getAccountLoginInfo(request);
        return Result.success().data(PageUtil.row(conNetworkOrderMobileService.getNetworkOrderListStatusQty(loginInfo, keyword)));
    }

    @ApiOperation("获取服务商工单列表")
    @PostMapping("/getNetworkOrderList")
    public Result getNetworkOrderList(HttpServletRequest request, @RequestBody NetworkMobileOrderListSelectVo selectVo) {
        AccounLoginInfo loginInfo = TokenNetworkUtil.getAccountLoginInfo(request);
        Map<String, Object> networkOrderList = conNetworkOrderMobileService.getNetworkOrderList(loginInfo, selectVo);
        return Result.success().data(networkOrderList);
    }

    @ApiOperation("服务商确认接单")
    @PostMapping("/networkSureReceiveOrder/{workId}")
    public Result networkSureReceiveOrder(HttpServletRequest request, @PathVariable @ApiParam(value = "工单ID", required = true) Long workId,
                                          @RequestBody JSONObject jsonObject) {
        AccounLoginInfo loginInfo = TokenNetworkUtil.getAccountLoginInfo(request);
        Integer expressCompany = jsonObject.getInteger("expressCompany");
        String expressNbr = jsonObject.getString("expressNbr");
        conNetworkOrderMobileService.networkSureReceiveOrder(loginInfo, workId, expressCompany, expressNbr);
        return Result.success("确认接单成功");
    }

    @ApiOperation("服务商拒绝接单")
    @PostMapping("/networkRefuseReceiveOrder/{workId}")
    public Result networkRefuseReceiveOrder(HttpServletRequest request, @PathVariable @ApiParam(value = "工单ID", required = true) Long workId,
                                            @RequestBody(required = false) @ApiParam(value = "拒绝接单的备注说明") @Valid RemarkVo remarkVo) {
        AccounLoginInfo loginInfo = TokenNetworkUtil.getAccountLoginInfo(request);
        conNetworkOrderMobileService.networkRefuseReceiveOrder(loginInfo, workId, remarkVo);
        return Result.success("拒绝接单成功");
    }

    @ApiOperation("获取服务商派单工程师")
    @PostMapping("/getNetworkDispatchEngineer")
    public Result getNetworkDispatchEngineer(HttpServletRequest request, @RequestBody SelectVo selectVo) {
        AccounLoginInfo loginInfo = TokenNetworkUtil.getAccountLoginInfo(request);
        return Result.success().data(conNetworkEmpService.getNetworkDispatchEngineer(loginInfo, selectVo));
    }

    @ApiOperation("服务商派工")
    @PostMapping("/networkDispatchEngineer/{workId}")
    public Result networkDispatchEngineer(HttpServletRequest request, @PathVariable @ApiParam(value = "工单ID", required = true) Long workId,
                                          @RequestBody @Valid NetworkMobileDispatchEngineerVo dispatchEngineerVo) {
        AccounLoginInfo loginInfo = TokenNetworkUtil.getAccountLoginInfo(request);
        conNetworkOrderMobileService.networkDispatchEngineer(loginInfo, workId, dispatchEngineerVo);
        return Result.success("派工成功");
    }

    @ApiOperation("服务商申请取消工单")
    @PostMapping("/networkApplyCancelOrder/{workId}")
    public Result networkApplyCancelOrder(HttpServletRequest request, @PathVariable @ApiParam(value = "工单ID", required = true) Long workId, @RequestBody @Valid RemarkVo remark) {
        AccounLoginInfo loginInfo = TokenNetworkUtil.getAccountLoginInfo(request);
        conNetworkOrderMobileService.networkApplyCancelOrder(loginInfo, workId, remark.getRemark());
        return Result.success("取消工单申请提交成功");
    }

    @ApiOperation("获取结单模板及字段")
    @GetMapping("/getFinishOrderTemplateField/{workId}")
    public Result getFinishOrderTemplateField(HttpServletRequest request, @PathVariable @ApiParam(value = "工单ID", required = true) Long workId) {
        AccounLoginInfo loginInfo = TokenNetworkUtil.getAccountLoginInfo(request);
        return Result.success().data(PageUtil.rows(conNetworkOrderMobileService.getFinishOrderTemplateField(loginInfo, workId)));
    }

    @ApiOperation("根据工单ID获取服务商结单信息")
    @GetMapping("/getNetworkStatementInfo/{workId}")
    public Result getNetworkStatement(@PathVariable @ApiParam(value = "工单ID", required = true) Long workId) {
        return Result.success().data(PageUtil.row(conNetworkOrderMobileService.getNetworkStatement(workId)));
    }

    @ApiOperation("根据工单ID获取结单码核销")
    @GetMapping("/getNetworkWriteOffCode/{workId}")
    public Result getNetworkStatementWriteOffCode(HttpServletRequest request, @PathVariable @ApiParam(value = "工单ID", required = true) Long workId) throws SMSException {
        AccounLoginInfo loginInfo = TokenNetworkUtil.getAccountLoginInfo(request);
        conNetworkOrderMobileService.getStatementWriteOffCode(loginInfo, workId);
        return Result.success();
    }

    @ApiOperation("服务工程师申请结单")
    @PostMapping("/networkApplyFinishOrder/{workId}")
    public Result networkApplyFinishOrder(HttpServletRequest request, @PathVariable @ApiParam(value = "工单ID", required = true) Long workId,
                                          @RequestBody NetworkMobileStatementVo statementVo) throws SMSException {
        AccounLoginInfo loginInfo = TokenNetworkUtil.getAccountLoginInfo(request);
        conNetworkOrderMobileService.networkApplyFinishOrder(loginInfo, workId, statementVo);
        return Result.success("结单申请提交成功");
    }

    @ApiOperation("提交服务商签单图")
    @PostMapping("/signImage")
    public Result signImage(@RequestBody JSONObject jsonObject) {
        // 从jsonObject中获取urls JSONArray
        JSONArray jsonArray = jsonObject.getJSONArray("urls");

        // 获取id
        Long id = jsonObject.getLong("id");
        List<String> urlsList = jsonArray.toJavaList(String.class);
        // 将List<String>转换为用逗号分隔的字符串
        String urlsStr = String.join(",", urlsList);

        ZjWorkOrder zjWorkOrder = new ZjWorkOrder();
        zjWorkOrder.setId(id);
        zjWorkOrder.setSignImage(urlsStr);
        conWorkOrderService.signImage(zjWorkOrder);
        return Result.success("提交服务商签单图");
    }

    @ApiOperation("工单详情")
    @GetMapping("/getNeworkOrderDetail/{workId}")
    public Result getNeworkOrderDetail(HttpServletRequest request, @PathVariable @ApiParam(value = "工单ID", required = true) Long workId) {
        AccounLoginInfo loginInfo = TokenNetworkUtil.getAccountLoginInfo(request);
        return Result.success().data(PageUtil.row(conNetworkOrderMobileService.getNeworkOrderDetail(loginInfo, workId)));
    }

    @ApiOperation("工单详情-工单")
    @GetMapping("/getNetworkOrderDetailContent/{workId}")
    public Result getNetworkOrderDetailContent(HttpServletRequest request, @PathVariable @ApiParam(value = "工单ID", required = true) Long workId) {
        AccounLoginInfo loginInfo = TokenNetworkUtil.getAccountLoginInfo(request);
        return Result.success().data(PageUtil.row(conNetworkOrderMobileService.getNetworkOrderDetailContent(loginInfo, workId)));
    }

    @ApiOperation("工单详情-商品")
    @GetMapping("/getNetworkOrderDetailGoods/{workId}")
    public Result getNetworkOrderDetailGoods(@PathVariable @ApiParam(value = "工单ID", required = true) Long workId) {
        return Result.success().data(PageUtil.row(conNetworkOrderMobileService.getNetworkOrderDetailGoods(workId)));
    }

    @ApiOperation("工单详情-商品-商品编码")
    @GetMapping("/getNetworkOrderDetailGoodsCode/{workGoodsId}")
    public Result getNetworkOrderDetailGoodsCode(@PathVariable @ApiParam(value = "工单商品ID", required = true) Long workGoodsId) {
        return Result.success().data(PageUtil.row(conNetworkOrderMobileService.getNetworkOrderDetailGoodsCode(workGoodsId)));
    }

    @ApiOperation("工单详情 - 根据工单ID获取最新进展")
    @GetMapping("/getNetworkOrderLastLog/{workId}")
    public Result getNetworkOrderLastLog(@PathVariable @ApiParam(value = "工单ID", required = true) Long workId) {
        return Result.success().data(PageUtil.row(workLogService.getOrderLastLogByWorkId(workId)));
    }

    @ApiOperation("工单详情-根据工单ID获取工单日志进展")
    @PostMapping("/getNetworkOrderLog/{workId}")
    public Result getNetworkOrderLog(@PathVariable @ApiParam(value = "工单ID", required = true) Long workId, @RequestBody PageUtil pageUtil) {
        PageUtil.setPageLimitMobile(pageUtil);
        return Result.success().data(workLogService.getOrderLogList(workId, pageUtil));
    }

    @ApiOperation("获取预约时间范围")
    @GetMapping("/getNetworkReservationTimeRange/{workId}")
    public Result getNetworkReservationTimeRange(@PathVariable @ApiParam(value = "工单ID", required = true) Long workId) {
        return Result.success().data(PageUtil.row(conNetworkOrderMobileService.getNetworkReservationTimeRange(workId)));
    }

    @ApiOperation("保存触发拨打电话")
    @PostMapping("/saveTriggerCallPhone/{workId}")
    public Result saveTriggerCallPhone(HttpServletRequest request, @PathVariable @ApiParam(value = "工单ID", required = true) Long workId) {
        AccounLoginInfo loginInfo = TokenNetworkUtil.getAccountLoginInfo(request);
        conNetworkOrderMobileService.saveTriggerCallPhone(loginInfo, workId);
        return Result.success();
    }

    @ApiOperation("保存拨打电话记录")
    @PostMapping("/saveCallPhoneLog/{workId}")
    public Result saveCallPhoneLog(HttpServletRequest request, @PathVariable @ApiParam(value = "工单ID", required = true) Long workId,
                                   @RequestBody @Valid WorkCallPhoneLogVo callPhoneLogVo) {
        AccounLoginInfo loginInfo = TokenNetworkUtil.getAccountLoginInfo(request);
        conNetworkOrderMobileService.saveCallPhoneLog(loginInfo, workId, callPhoneLogVo);
        return Result.success("保存拨打电话记录成功");
    }

    @ApiOperation("预约时间")
    @PostMapping("/networkReservationTime")
    public Result networkReservationTime(HttpServletRequest request, @RequestBody @Valid OrderReservationTimeVo orderReservationTimeVo) {
        AccounLoginInfo loginInfo = TokenNetworkUtil.getAccountLoginInfo(request);
        conNetworkOrderMobileService.networkReservationTime(loginInfo, orderReservationTimeVo);
        return Result.success("预约时间成功");
    }
    // todo 重复预约时间

    @ApiOperation("工程师申请转单/转派工程师/服务商直接转派工单师")
    @PostMapping("/networkApplyTransferEngineer/{workId}")
    public Result networkApplyTransferEngineer(HttpServletRequest request, @PathVariable @ApiParam(value = "工单ID", required = true) Long workId,
                                               @RequestBody @ApiParam(value = "转单原因备注", required = true) @Valid RemarkVo remark) {
        AccounLoginInfo loginInfo = TokenNetworkUtil.getAccountLoginInfo(request);
        conNetworkOrderMobileService.networkApplyTransferEngineer(loginInfo, workId, remark.getRemark());
        return Result.success("转派工程师申请成功");
    }

    @ApiOperation("服务商审核工程师转单申请")
    @PostMapping("/networkCheckTransferEngineer")
    public Result networkCheckTransferEngineer(HttpServletRequest request, @RequestBody @Valid NetworkMobileCheckTransferEngineerVo transferEngineerVo) {
        AccounLoginInfo loginInfo = TokenNetworkUtil.getAccountLoginInfo(request);
        conNetworkOrderMobileService.networkCheckTransferEngineer(loginInfo, transferEngineerVo);
        return Result.success("审核工程师转单申请成功");
    }

    @ApiOperation("申请改派服务商")
    @PostMapping("/networkApplyChangeNetwork/{workId}")
    public Result networkApplyChangeNetwork(HttpServletRequest request, @PathVariable @ApiParam(value = "工单ID", required = true) Long workId,
                                            @RequestBody @ApiParam(value = "改派原因备注", required = true) @Valid RemarkVo remark) {
        AccounLoginInfo loginInfo = TokenNetworkUtil.getAccountLoginInfo(request);
        conNetworkOrderMobileService.networkApplyChangeNetwork(loginInfo, workId, remark.getRemark());
        return Result.success("申请改派服务商，等待总部客服审核");
    }

    @ApiOperation("取消改派服务商申请")
    @PostMapping("/networkCancelChangeNetworkApply/{workId}")
    public Result networkCancelChangeNetworkApply(HttpServletRequest request, @PathVariable @ApiParam(value = "工单ID", required = true) Long workId,
                                                  @RequestBody(required = false) @ApiParam(value = "取消改派原因备注") @Valid RemarkVo remark) {
        AccounLoginInfo loginInfo = TokenNetworkUtil.getAccountLoginInfo(request);
        conNetworkOrderMobileService.networkCancelChangeNetworkApply(loginInfo, workId, remark.getRemark());
        return Result.success("改派服务商申请取消成功");
    }

    @ApiOperation("根据工单ID获取工单挂起设置")
    @GetMapping("/getOrderSuspendConfig/{workId}")
    public Result getOrderSuspendConfig(@PathVariable @ApiParam(value = "工单ID", required = true) Long workId) {
        return Result.success().data(PageUtil.row(workSuspendService.getOrderSuspendConfig(workId)));
    }

    @ApiOperation("服务工程师申请工单挂起")
    @PostMapping("/networkEmpApplySuspendOrder/{workId}")
    public Result networkEmpApplySuspendOrder(HttpServletRequest request, @PathVariable @ApiParam(value = "工单ID", required = true) Long workId,
                                         @RequestBody @Valid NetworkMobileWorkSuspendVo workSuspendVo) {
        AccounLoginInfo loginInfo = TokenNetworkUtil.getAccountLoginInfo(request);
        workSuspendService.networkEmpApplySuspend(loginInfo, workId, workSuspendVo);
        return Result.success("申请工单挂起成功，等待审核");
    }

    @ApiOperation("服务工程师取消工单挂起")
    @PostMapping("/networkEmpRestartSuspendOrder/{workId}")
    public Result networkEmpRestartSuspendOrder(HttpServletRequest request, @PathVariable @ApiParam(value = "工单ID", required = true) Long workId) {
        AccounLoginInfo loginInfo = TokenNetworkUtil.getAccountLoginInfo(request);
        workSuspendService.networkEmpRestartSuspendOrder(loginInfo, workId);
        return Result.success("取消工单挂起成功");
    }

    @ApiOperation("根据工单ID获取是否开启签到")
    @GetMapping("/getNetworkEmpIsEnableSign/{workId}")
    public Result getNetworkEmpIsEnableSign(@PathVariable @ApiParam(value = "工单ID", required = true) Long workId) {
        return Result.success().data(PageUtil.row(conWorkOrderService.getNetworkEmpIsEnableSign(workId)));
    }

    @ApiOperation("根据工单ID获取签到设置")
    @GetMapping("/getNetworkEmpSignSet/{workId}")
    public Result getNetworkEmpSignSet(@PathVariable @ApiParam(value = "工单ID", required = true) Long workId) {
        return Result.success().data(PageUtil.row(conWorkOrderService.getNetworkEmpMobileSignSet(workId)));
    }

    @ApiOperation("工程师签到")
    @PostMapping("/networkEngineerSign/{workId}")
    public Result networkEngineerSign(HttpServletRequest request, @PathVariable @ApiParam(value = "工单ID", required = true) Long workId,
                                      @RequestBody @Valid NetworkMobileEngineerSignVo engineerSignVo) {
        AccounLoginInfo loginInfo = TokenNetworkUtil.getAccountLoginInfo(request);
        return Result.success("签到成功").data(PageUtil.row(conNetworkOrderMobileService.networkEngineerSign(loginInfo, workId, engineerSignVo)));
    }

    @ApiOperation("根据工单ID获取是否费用全包")
    @GetMapping("/getOrderAllInclusiveFee/{workId}")
    public Result getOrderAllInclusiveFee(@PathVariable @ApiParam(value = "工单ID", required = true) Long workId) {
        return Result.success().data(PageUtil.row(conNetworkOrderMobileService.getOrderAllInclusiveFeeByWorkId(workId)));
    }

    @ApiOperation("保存申请费用")
    @PostMapping("/saveApplyFee/{workId}")
    public Result saveApplyFee(HttpServletRequest request, @PathVariable @ApiParam(value = "工单ID", required = true) Long workId,
                               @RequestBody @Valid NetworkMobileOrderFeeVo orderFeeVo) {
        AccounLoginInfo loginInfo = TokenNetworkUtil.getAccountLoginInfo(request);
        conNetworkOrderMobileService.saveApplyFee(loginInfo, workId, orderFeeVo);
        return Result.success("申请工单服务费成功");
    }

    @ApiOperation("获取工单客户地址")
    @GetMapping("/getMobileWorkUserAddress/{workId}")
    public Result getWorkUserAddress(@PathVariable @ApiParam(value = "工单ID", required = true) Long workId) {
        return Result.success("获取工单客户地址成功").data("row", workUserService.getWorkUserAddress(workId));
    }

    @ApiOperation("获取服务商地址")
    @GetMapping("/getMobileOrderNetworkAddress/{workId}")
    public Result getOrderNetworkAddress(@PathVariable @ApiParam(value = "工单ID", required = true) Long workId) {
        return Result.success("获取服务商地址成功").data("row", conWorkOrderService.getOrderNetworkAddress(workId));
    }

    @ApiOperation("保存申请工单配件")
    @PostMapping("/saveApplySpare")
    public Result saveApplySpare(HttpServletRequest request, @RequestBody @Valid WorkSpareVo workSpareVo) {
        AccounLoginInfo loginInfo = TokenNetworkUtil.getAccountLoginInfo(request);
        conNetworkOrderMobileService.saveApplySpare(loginInfo, workSpareVo);
        return Result.success("申请工单服务费成功");
    }

    @ApiOperation("获取费用信息")
    @GetMapping("/getOrderFeeInfo/{workId}")
    public Result getOrderFeeInfo(@PathVariable @ApiParam(value = "工单ID", required = true) Long workId) {
        return Result.success().data(PageUtil.rows(conNetworkOrderMobileService.getOrderFeeInfo(workId)));
    }


}
